Skip to content

Commit

Permalink
Merge branch 'timschneeb:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
YexuanXiao authored Jun 17, 2024
2 parents f0a329c + eae9fa1 commit 8ac42b6
Show file tree
Hide file tree
Showing 9 changed files with 7,747 additions and 18 deletions.
42 changes: 26 additions & 16 deletions GalaxyBudsClient.Platform.Linux/BluetoothService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,21 +463,21 @@ private async void BluetoothServiceLoop()
return;
}

var hasIoActivity = false;
bool hasIoActivity;
try
{
var incomingCount = _profile.Stream?.AvailableBytes;
if (incomingCount == null)
{
/* Stream not yet ready */
await Task.Delay(100);
continue;
}

if (incomingCount > 0)
{
IsStreamConnected = true;
hasIoActivity = true;


/* Handle incoming stream */
var buffer = new byte[incomingCount ?? 0];
var dataAvailable = false;
Expand All @@ -501,25 +501,35 @@ private async void BluetoothServiceLoop()
/* Handle outgoing stream */
lock (TransmitterQueue)
{
if (TransmitterQueue.IsEmpty) continue;
if (!TransmitterQueue.TryDequeue(out var raw)) continue;
hasIoActivity = true;
try
{
_profile.Stream?.Write(raw, 0, raw.Length);
}
catch (SocketException ex)
if (TransmitterQueue.IsEmpty || !TransmitterQueue.TryDequeue(out var raw))
{
Log.Error("Linux.BluetoothService: BluetoothServiceLoop: SocketException thrown while writing unsafe stream: {ExMessage}. Cancelled", ex.Message);
Disconnected?.Invoke(this, ex.Message);
hasIoActivity = false;
}
catch (IOException ex)
else
{
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(SocketException))
hasIoActivity = true;

try
{
_profile.Stream?.Write(raw, 0, raw.Length);
}
catch (SocketException ex)
{
Log.Error("Linux.BluetoothService: BluetoothServiceLoop: IO and SocketException thrown while writing unsafe stream: {ExMessage}. Cancelled", ex.Message);
Log.Error(
"Linux.BluetoothService: BluetoothServiceLoop: SocketException thrown while writing unsafe stream: {ExMessage}. Cancelled",
ex.Message);
Disconnected?.Invoke(this, ex.Message);
}
catch (IOException ex)
{
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(SocketException))
{
Log.Error(
"Linux.BluetoothService: BluetoothServiceLoop: IO and SocketException thrown while writing unsafe stream: {ExMessage}. Cancelled",
ex.Message);
Disconnected?.Invoke(this, ex.Message);
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion GalaxyBudsClient/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<TrayIcon.Icons>
<TrayIcons>
<TrayIcon Menu="{Binding TrayMenu, DataType=galaxyBudsClient:App}"
Icon="{OnPlatform '/Resources/icon_white_tray.ico', macOS='/Resources/icon_black_tray.ico'}"
Icon="{OnPlatform '/Resources/icon_white_outlined_multi_tray.ico', Windows='/Resources/icon_white_outlined_single_tray.ico', macOS='/Resources/icon_black_tray.ico'}"
MacOSProperties.IsTemplateIcon="true"
ToolTipText="Galaxy Buds"
Clicked="TrayIcon_OnClicked" />
Expand Down
Binary file not shown.
Binary file not shown.
3,892 changes: 3,892 additions & 0 deletions GalaxyBudsClient/Resources/icon_white_outlined_single_tray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,826 changes: 3,826 additions & 0 deletions GalaxyBudsClient/Resources/icon_white_outlined_tray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion GalaxyBudsClient/Utils/Interface/WindowIconRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ private static WindowIcon MakeDefaultIcon()
private static Bitmap MakeDefaultBitmap()
{
// OSX uses templated icons
var uri = $"{Program.AvaresUrl}/Resources/icon_{(PlatformUtils.IsOSX ? "black" : "white")}_tray.ico";
var type = PlatformUtils.IsOSX ? "black" : PlatformUtils.IsWindows ? "white_outlined_single" : "white_outlined_multi";
var uri = $"{Program.AvaresUrl}/Resources/icon_{type}_tray.ico";
return new Bitmap(AssetLoader.Open(new Uri(uri)));
}
}

0 comments on commit 8ac42b6

Please sign in to comment.