SpriteOvO / AirPodsDesktop

☄️ AirPods desktop user experience enhancement program, for Windows and Linux (WIP)
GNU General Public License v3.0
1.47k stars 87 forks source link

[Feature Request] Hope to support [ Airpods Pro 2(USB-C) 2023 ] #90

Closed MrBeanCpp closed 11 months ago

MrBeanCpp commented 11 months ago

:cloud_with_rain: Is your feature request related to a problem? Please describe.

Hope to support [ Airpods Pro 2(USB-C) 2023 ]

:partly_sunny: Describe the solution you'd like

Just add a Swtich Case in function [ Core::AirPods::Model AirPods::GetModel(uint16_t modelId) ]

SpriteOvO commented 11 months ago

@MrBeanCpp Hi! I'm willing to support it. Do you have the model ID of AirPods Pro 2 (USB-C)? Or if you have the device, you can launch AirPodsDesktop with --trace argument, then post the log file here.

MrBeanCpp commented 11 months ago

@SpriteOvO Okay,I have the device and I'm trying to build the project in my Windows 11. The model ID of AirPods Pro 2 (USB-C) is 0x2024 I've tested it & it works. ( with new enum: AirPods_Pro_2_USB_C) (Maybe I can do something to help.)

Other Problems

I'm suffering some problems while building & runing. Can you help me?

  1. static_assert(false); in Source/Logger.h:63 This Line breaks the building process and I can't continue. So I fixed it into assert(false); and then it runs well. But I don't know why.
  2. If I open & close my airpods box repeatedly, sometimes the airpods rotation animation in the pop-up widget disappears and becomes blank, showing the behind window. Like this: image The testing airpods is AirPods Pro 2 (USB-C)
SpriteOvO commented 11 months ago

Thanks for the information, I will support the new device later.


static_assert(false); in Source/Logger.h:63 This Line breaks the building process and I can't continue. So I fixed it into assert(false); and then it runs well. But I don't know why.

You can simply comment it out to workaround.

The reason is: Before C++ 23, the first argument of static_assert must be contextually related to the template type, so just a false will always be visible to the compiler, no matter what if constexpr branch it's under. Early implementations of this in MSVC were not standards-compliant, so it allowed this usage. You may be using a newer version of MSVC so it starts complaining about this error. And a fun fact: since C++ 23, the standard has allowed this usage.

I plan to completely upgrade the build toolchains and dependencies for this project later to fix this issue.

If I open & close my airpods box repeatedly, sometimes the airpods rotation animation in the pop-up widget disappears and becomes blank, showing the behind window.

If the AirPodsDesktop on the Release Page doesn't have this problem, a guess is that you may be compiling the project in Debug. Try switching to Release.

MrBeanCpp commented 11 months ago

@SpriteOvO Thank you for your explanation. Today & yesterday, I'm working on figuring out the reason about the display problem(blank & lag ).

The reason is:I've installed LAVFilters for QMediaPlayer to play .mp3 last year and it doesn't seem to work well for Video files(.avi) The solution is:

in order to make QMediaPlayer works good for mp3 & avi

And I wrote a blog to explain this:QMediaPlayer与解码器浅析

And maybe I can submit a PR to support Airpods Pro 2(USB-C)

SpriteOvO commented 11 months ago

And I wrote a blog to explain this:QMediaPlayer与解码器浅析

Wow, amazing. BTW, Qt no longer uses native codecs anymore since 6.5, but uses built-in ffmpeg as a backend. This should get rid of all this chaos.

And maybe I can submit a PR to support Airpods Pro 2(USB-C)

That's even better. 👍 For animation, I think we can reuse the one for AirPods Pro 2 since they probably have no appearance difference except for the charging port.

MrBeanCpp commented 11 months ago

Wow, amazing. BTW, Qt no longer uses native codecs anymore since 6.5, but uses built-in ffmpeg as a backend. This should get rid of all this chaos.

Good news! (Even though migrating the dev environment is a huge project)

For animation, I think we can reuse the one for AirPods Pro 2 since they probably have no appearance difference except for the charging port.

Yes, that's what I think. Just add one more case under Airpods Pro 2:

case Core::AirPods::Model::AirPods_Pro_2:
case Core::AirPods::Model::AirPods_Pro_2_USB_C:
  media = "qrc:/Resource/Video/AirPods_Pro_2.avi";
  videoSize = QSize{900, 450};
  break;

I'm glad to be able to contribute codes. This is my first time participating in open source project, and I am learning the correct process. Thank you for your patience.

MrBeanCpp commented 11 months ago

@SpriteOvO I found that every time I build the project, the .ts files will re-generate automatically. Should I ignore the changes of them when I commit. // The changes are about line break(LF & CRLF) & strange sth. in zh_TW.ts

MrBeanCpp commented 11 months ago

@SpriteOvO Something strange happened: the advState.model continuously switchs between Airpods 2 & AirPods Pro 2(USB-C) and I just open the airpods box. Like this:

[warning] [AirPods.cpp:218] IsPossibleDesiredAdv returns false. Reason: model new='AirPods 2' old='AirPods Pro 2(USB-C)'

So that sometimes the animation also swtichs between them(Low frequency). But I have only one AirPods Pro 2(USB-C) besides me


Here's the main changes I've made. AppleCP.cpp

case 0x2014:
    return Core::AirPods::Model::AirPods_Pro_2;
case 0x2024:
    return Core::AirPods::Model::AirPods_Pro_2_USB_C;

MainWindow.cpp

case Core::AirPods::Model::AirPods_Pro_2:
case Core::AirPods::Model::AirPods_Pro_2_USB_C:
    media = "qrc:/Resource/Video/AirPods_Pro_2.avi";
    videoSize = QSize{900, 450};
    break;
SpriteOvO commented 11 months ago

I found that every time I build the project, the .ts files will re-generate automatically. Should I ignore the changes of them when I commit. // The changes are about line break(LF & CRLF) & strange sth. in zh_TW.ts

You should ignore them, on my own machine I set the git options for LF & CRLF so that even if I commit them, they don't show up in the history commits (they are automatically discarded).

Something strange happened: the advState.model continuously switchs between Airpods 2 & AirPods Pro 2(USB-C) and I just open the airpods box.

One guess, they may have only replaced the charging case, for pods, the old model is still compatible, so they are not designed as a new model. Based on the guess, the charging case could be emitting the new value 0x2024 while the pods are still emitting the old value 0x2014, which would cause AirPodsDesktop to get confused. If I'm correct, you should be able to confirm this in the --trace logs.

As a solution, instead of adding a new enum value AirPods_Pro_2_USB_C, we could just recognize both 0x2014 and 0x2024 as AirPods_Pro_2, which I think might be fine.

case 0x2014:
case 0x2024:
    return Core::AirPods::Model::AirPods_Pro_2;
MrBeanCpp commented 11 months ago

You should ignore them

Okay

Based on the guess, the charging case could be emitting the new value 0x2024 while the pods are still emitting the old value 0x2014

There may be some misunderstandings here. It switchs between AirPods 2 (NOT AirPods Pro 2) & AirPods Pro 2(USB-C). So it confused me. QAQ

SpriteOvO commented 11 months ago

Can you post your log files to here, and commit + push your current changes to your forked repo? I have no idea if there isn't much information.

MrBeanCpp commented 11 months ago

Sorry, the debug log is here: AirPodsDesktop.log


At present, there is no problem with the display effect, but there are some issues in the log Like this:

[2023-09-27 21:25:11.769] [Main] [trace] [AirPods.cpp:541] AirPods advertisement received. Data: 07 19 01 24 20 35 aa b6 11 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, Address Hash: 18289495276256941894, RSSI: -62
[2023-09-27 21:25:11.923] [Main] [trace] [AirPods.cpp:541] AirPods advertisement received. Data: 07 19 01 24 20 55 aa b6 11 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, Address Hash: 17793804701058576843, RSSI: -45
[2023-09-27 21:25:11.924] [Main] [trace] [AirPods.cpp:541] AirPods advertisement received. Data: 07 19 01 24 20 55 aa b6 11 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, Address Hash: 17793804701058576843, RSSI: -45
[2023-09-27 21:25:11.947] [Main] [trace] [AirPods.cpp:541] AirPods advertisement received. Data: 07 19 01 24 20 55 aa b6 11 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, Address Hash: 17793804701058576843, RSSI: -42
[2023-09-27 21:25:11.963] [Main] [trace] [AirPods.cpp:541] AirPods advertisement received. Data: 07 19 01 0f 20 2b 99 8f 01 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, Address Hash: 2728661321614142570, RSSI: -71
[2023-09-27 21:25:11.963] [Main] [warning] [AirPods.cpp:218] IsPossibleDesiredAdv returns false. Reason: model new='AirPods 2' old='AirPods Pro 2(USB-C)'
[2023-09-27 21:25:11.963] [Main] [warning] [AirPods.cpp:170] This adv may not be broadcast from the device we desire.

Here is my forked repo: https://github.com/MrBeanCpp/AirPodsDesktop

SpriteOvO commented 11 months ago

Hmm, It's strange indeed, I don't have a clue at the moment.

You can open a PR to merge the current changes into the main branch, and then I'll release a new version later to see if anyone else has this issue.

MrBeanCpp commented 11 months ago

@SpriteOvO Okay, I had opened a PR. #91

But something more strange happened. Everything seems Okay today. No Bug. No Warning.

I don't know why it broken & why it runs

Is this the charm of programming

SpriteOvO commented 11 months ago

@SpriteOvO Okay, I had opened a PR. #91

But something more strange happened. Everything seems Okay today. No Bug. No Warning.

I don't know why it broken & why it runs

Is this the charm of programming

Lol. Thanks. I'm reviewing the PR.

SpriteOvO commented 11 months ago

Implemented in PR #91